package cn.home.sysmanagement.controller;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.sysmanagement.domain.HomeDoctorMessage;
import cn.home.sysmanagement.service.IHomeDoctorMessageService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 公告-医生中间Controller
 * 
 * @author homedoctor
 * @date 2025-04-10
 */
@RestController
@RequestMapping("/sysmanagement/docmessage")
public class HomeDoctorMessageController extends BaseController
{
    @Autowired
    private IHomeDoctorMessageService homeDoctorMessageService;

    /**
     * 查询公告-医生中间列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeDoctorMessage homeDoctorMessage)
    {
        startPage();
        List<HomeDoctorMessage> list = homeDoctorMessageService.selectHomeDoctorMessageList(homeDoctorMessage);
        return getDataTable(list);
    }

    /**
     * 导出公告-医生中间列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:export')")
    @Log(title = "公告-医生中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeDoctorMessage homeDoctorMessage)
    {
        List<HomeDoctorMessage> list = homeDoctorMessageService.selectHomeDoctorMessageList(homeDoctorMessage);
        ExcelUtil<HomeDoctorMessage> util = new ExcelUtil<HomeDoctorMessage>(HomeDoctorMessage.class);
        util.exportExcel(response, list, "公告-医生中间数据");
    }

    /**
     * 获取公告-医生中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:query')")
    @GetMapping(value = "/{doctorid}")
    public AjaxResult getInfo(@PathVariable("doctorid") Long doctorid)
    {
        return success(homeDoctorMessageService.selectHomeDoctorMessageByDoctorid(doctorid));
    }

    /**
     * 新增公告-医生中间
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:add')")
    @Log(title = "公告-医生中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeDoctorMessage homeDoctorMessage)
    {
        homeDoctorMessage.setrelasetime(new Date());

        return toAjax(homeDoctorMessageService.insertHomeDoctorMessage(homeDoctorMessage));
    }

    /**
     * 修改公告-医生中间
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:edit')")
    @Log(title = "公告-医生中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeDoctorMessage homeDoctorMessage)
    {
        return toAjax(homeDoctorMessageService.updateHomeDoctorMessage(homeDoctorMessage));
    }

    /**
     * 删除公告-医生中间
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:docmessage:remove')")
    @Log(title = "公告-医生中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{doctorids}")
    public AjaxResult remove(@PathVariable Long[] doctorids)
    {
        return toAjax(homeDoctorMessageService.deleteHomeDoctorMessageByDoctorids(doctorids));
    }
}
